const app = getApp();
const publicFun = require('/utils/public');
import { getCertificateList } from '/utils/request'
Page({
  data: {},
  onLoad() {
    my.setNavigationBarColor({
      frontColor: '#000000',
      backgroundColor: '#ffffff',
    })
    let systemInfo = app.globalData.systemInfo;
    this.setData({
      systemInfo: systemInfo,
    });
    this.getRewardList();
  },
  applyDetailTap(e) {
    let id = e.currentTarget.dataset.id
    my.navigateTo({
      url: '/pages/myCertificateDetail/myCertificateDetail?id='+id
    })
  },
  async getRewardList() { 
    try{
      var params = {
        typeid: 1
      }
      const res = await getCertificateList(params)
      if(res.S == 1){
        let data = res;
        let list = [];
        data.L.forEach(item => {
          if(item.id == 14 || item.id == 29) {
            list.push(item)
          }
        });
        this.setData({ rewardList: list })
      }else{
        publicFun.showToast(res.M ? res.M : '加载失败')
      }
    }catch(e){
      publicFun.showToast('失败，请稍后再试')
    }
  },
});
